import { useModel } from "umi";
import { useReactive } from "ahooks";
import { useEffect } from "react";

import { UpdateApplicationPriceByAiUuid } from "../_graphql/application";

const useApplication = () => {
    const { graphqlFetchPlatform } = useModel("global");

    const state = useReactive({
        apploading: false,
        applications: [],
    });

    const updatePrice = async (aiUuid, values, callback) => {
        let res = await graphqlFetchPlatform({
            query: UpdateApplicationPriceByAiUuid,
            variables: { aiUuid, ...values },
        });
        if (res) {
            callback && callback(res);
        }
    };

    return { ...state, updatePrice };
};

export default useApplication;
